{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Imports\n",
    "\n",
    "Import all the modules and functionalities we need."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "\n",
    "# Import standard libraries.\n",
    "from collections import defaultdict\n",
    "import itertools\n",
    "from IPython.display import Image\n",
    "import os\n",
    "\n",
    "# Import third party libraries.\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "import scipy.signal as sign\n",
    "import scipy.stats as stats\n",
    "from statsmodels.stats.multitest import multipletests\n",
    "\n",
    "# Import custom libraries/scripts.\n",
    "import annotations\n",
    "import helpers\n",
    "import helpers_mod"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Loading data\n",
    "\n",
    "Fetch all our relevant data for the current analysis."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set working contants.\n",
    "EXPERIMENTS_PATH = r'\\\\10.40.12.80\\home\\PhD\\Results\\Competition\\DL\\Four-Arena Setup\\WT_mating_status\\processed'\n",
    "FPS = 60\n",
    "N_MINUTES = 60\n",
    "N_FRAMES = N_MINUTES * 60 * FPS\n",
    "INK = 'black'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set figure configurations.\n",
    "sns.set(\n",
    "        context='paper',\n",
    "        style='ticks',\n",
    "        font='sans-serif',\n",
    "        font_scale=1.0, \n",
    "        rc={\n",
    "            'axes.axisbelow': True,\n",
    "            'axes.edgecolor': INK,\n",
    "            'axes.facecolor': 'white' if INK=='black' else 'black',\n",
    "            'axes.grid': False,\n",
    "            'axes.labelcolor': INK,\n",
    "            'axes.labelsize': 13.0,\n",
    "            'axes.labelweight': 'normal',\n",
    "            'axes.linewidth': 1.0,\n",
    "            'axes.spines.left': True,\n",
    "            'axes.spines.bottom': True,\n",
    "            'axes.spines.top': False,\n",
    "            'axes.spines.right': False,\n",
    "            'axes.titlepad': 15.0,\n",
    "            'axes.titlesize': 20.0,\n",
    "            'axes.titleweight': 'bold',\n",
    "            'figure.facecolor': 'white' if INK=='black' else 'black',\n",
    "            'figure.figsize': [6.0, 4.0],\n",
    "            'figure.titlesize': 30.0,\n",
    "            'figure.titleweight': 'bold',\n",
    "            'font.family': ['sans-serif'],\n",
    "            'font.sans-serif': ['Arial'],\n",
    "            'legend.frameon': False,\n",
    "            'legend.fontsize': 11.0,\n",
    "            'lines.color': INK,\n",
    "            'lines.linewidth': 1.0,\n",
    "            'patch.edgecolor': INK,\n",
    "            'savefig.dpi': 300,\n",
    "            'savefig.format': 'png',\n",
    "            'savefig.bbox': 'tight',\n",
    "            'savefig.transparent': True,\n",
    "            'text.color': INK,\n",
    "            'text.usetex': False,\n",
    "            'xtick.color': INK,\n",
    "            'xtick.direction': 'out',\n",
    "            'xtick.labelsize': 12.0,\n",
    "            'xtick.major.pad': 5.0,\n",
    "            'xtick.major.size': 0.0,\n",
    "            'xtick.major.width': 1.0,\n",
    "            'xtick.minor.size': 0.0,\n",
    "            'xtick.minor.width': 0.4,\n",
    "            'ytick.color': INK,\n",
    "            'ytick.direction': 'out',\n",
    "            'ytick.labelsize': 12.0,\n",
    "            'ytick.major.pad': 5.0,\n",
    "            'ytick.major.size': 3.0,\n",
    "            'ytick.major.width': 1.0,\n",
    "            'ytick.minor.size': 0.0,\n",
    "            'ytick.minor.width': 0.4\n",
    "           }\n",
    "       )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Folder already exists, skipping.\n"
     ]
    }
   ],
   "source": [
    "# Prepare the Figures folder to save our graphs in.\n",
    "savepath = os.path.join(r'C:\\Users\\Miguel\\Desktop\\paper_data', 'paper_figures', 'figure1')\n",
    "try:\n",
    "    os.makedirs(savepath)\n",
    "    print('New folder created.')\n",
    "except FileExistsError:\n",
    "    print('Folder already exists, skipping.')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Paths to conditions:\n",
      " ['\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin']\n"
     ]
    }
   ],
   "source": [
    "# Set the conditions to analyze.\n",
    "condition_order = ['virgin_virgin']\n",
    "conditions = [item.path for item in os.scandir(EXPERIMENTS_PATH) if item.name in condition_order]\n",
    "print('Paths to conditions:\\n', conditions)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['video_2017-09-05T15_42_04_arena3', 'video_2017-09-07T13_28_02_arena4']\n",
      "2\n"
     ]
    }
   ],
   "source": [
    "# Create a list of all the experiments that we DO NOT want to analyze.\n",
    "intruders = []\n",
    "for condition in conditions:\n",
    "    for file in os.listdir(condition):\n",
    "        if 'quality_control' in file:\n",
    "\n",
    "            # Read the quality.csv file to check which experiments are usable for analysis.\n",
    "            quality_file = os.path.join(condition, file)\n",
    "            quality_df = pd.read_csv(quality_file, usecols=[0,1], index_col=0)\n",
    "            quality_df = quality_df[quality_df['is_usable'] == False].index.values\n",
    "            \n",
    "            for value in quality_df:\n",
    "                intruders.append(value)\n",
    "\n",
    "print(intruders)             \n",
    "print(len(intruders))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\t\n",
      " virgin_virgin\n",
      "Copulation too short: video_2017-09-06T13_42_13_arena3\n",
      "Copulation too short: video_2017-09-26T14_52_18_arena3\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'virgin_virgin': ['\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-05T13_28_41_arena4',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-05T14_34_55_arena2',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-06T13_42_13_arena1',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-06T14_45_32_arena3',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-07T14_37_38_arena3',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-07T14_37_38_arena4',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-08T13_26_13_arena3',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-12T13_30_06_arena4',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-12T14_36_55_arena3',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-12T16_18_15_arena4',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-13T14_34_18_arena2',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-20T13_43_53_arena3',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-20T14_48_55_arena2',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-21T13_38_55_arena4',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-21T15_57_23_arena2',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-26T13_40_19_arena1',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-28T13_36_06_arena4',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-28T14_44_01_arena3',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-09-28T15_55_49_arena3',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-10-12T15_50_43_arena2',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-10-13T16_06_33_arena2',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-10-18T15_19_17_arena3',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-10-19T13_50_56_arena2',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-10-20T13_21_06_arena2',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-10-20T15_44_09_arena2',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-10-24T16_13_35_arena4',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-10-25T14_55_12_arena1',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-11-02T13_37_48_arena3',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-11-02T14_48_28_arena4',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-11-02T16_11_06_arena3',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-11-03T14_54_45_arena1',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-11-03T16_20_50_arena4',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-12-20T12_58_51_arena4',\n",
       "  '\\\\\\\\10.40.12.80\\\\home\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\Four-Arena Setup\\\\WT_mating_status\\\\processed\\\\virgin_virgin\\\\video_2017-12-20T14_01_01_arena3']}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Load all usable experiments for each condition.\n",
    "experiments = {condition: [] for condition in condition_order}\n",
    "\n",
    "for condition_path in conditions:\n",
    "    \n",
    "    condition = os.path.basename(condition_path)\n",
    "    print('\\t\\n', condition)\n",
    "    \n",
    "    for item in os.scandir(condition_path):\n",
    "        if item.is_dir() and item.name not in intruders:\n",
    "\n",
    "            annotation_video = annotations.read(item.path + '.csv')\n",
    "            \n",
    "            try:\n",
    "                copulation = annotation_video[0].events[0]\n",
    "\n",
    "                # Filter out videos where copulation is interrupted.\n",
    "                copulation_end = copulation.time_interval[1]\n",
    "                if copulation_end==N_FRAMES:\n",
    "                    print('Copulation interrupted:', item.name)\n",
    "                    continue\n",
    "\n",
    "                # Filter out videos where copulation lasts less than 8 minutes.\n",
    "                copulation_duration = copulation.duration\n",
    "                if copulation_duration <= 8 * 60 * FPS:\n",
    "                    print('Copulation too short:', item.name)\n",
    "                    continue\n",
    "            \n",
    "            except IndexError:\n",
    "                continue\n",
    "\n",
    "            experiments[condition].append(item.path)\n",
    "\n",
    "experiments"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "virgin_virgin \n",
      "\n",
      "video_2017-09-05T13_28_41_arena4\n",
      "No aggression for this experiment\n",
      "\n",
      "video_2017-09-05T14_34_55_arena2\n",
      "Number of aggressive bouts is: 6\n",
      "Number of clean detected \"encounters\" is: 11\n",
      "Number of detected aggressive bouts is: 6\n",
      "1.0 \n",
      "\n",
      "video_2017-09-06T13_42_13_arena1\n",
      "Number of aggressive bouts is: 3\n",
      "Number of clean detected \"encounters\" is: 14\n",
      "Number of detected aggressive bouts is: 3\n",
      "1.0 \n",
      "\n",
      "video_2017-09-06T14_45_32_arena3\n",
      "Number of aggressive bouts is: 11\n",
      "Number of clean detected \"encounters\" is: 10\n",
      "Number of detected aggressive bouts is: 11\n",
      "1.0 \n",
      "\n",
      "video_2017-09-07T14_37_38_arena3\n",
      "Number of aggressive bouts is: 7\n",
      "Number of clean detected \"encounters\" is: 3\n",
      "Number of detected aggressive bouts is: 0\n",
      "0.0 \n",
      "\n",
      "video_2017-09-07T14_37_38_arena4\n",
      "Number of aggressive bouts is: 3\n",
      "Number of clean detected \"encounters\" is: 9\n",
      "Number of detected aggressive bouts is: 3\n",
      "1.0 \n",
      "\n",
      "video_2017-09-08T13_26_13_arena3\n",
      "Number of aggressive bouts is: 8\n",
      "Number of clean detected \"encounters\" is: 26\n",
      "Number of detected aggressive bouts is: 8\n",
      "1.0 \n",
      "\n",
      "video_2017-09-12T13_30_06_arena4\n",
      "No aggression for this experiment\n",
      "\n",
      "video_2017-09-12T14_36_55_arena3\n",
      "No aggression for this experiment\n",
      "\n",
      "video_2017-09-12T16_18_15_arena4\n",
      "Number of aggressive bouts is: 2\n",
      "Number of clean detected \"encounters\" is: 9\n",
      "Number of detected aggressive bouts is: 2\n",
      "1.0 \n",
      "\n",
      "video_2017-09-13T14_34_18_arena2\n",
      "Number of aggressive bouts is: 4\n",
      "Number of clean detected \"encounters\" is: 20\n",
      "Number of detected aggressive bouts is: 4\n",
      "1.0 \n",
      "\n",
      "video_2017-09-20T13_43_53_arena3\n",
      "No aggression for this experiment\n",
      "\n",
      "video_2017-09-20T14_48_55_arena2\n",
      "No aggression for this experiment\n",
      "\n",
      "video_2017-09-21T13_38_55_arena4\n",
      "Number of aggressive bouts is: 1\n",
      "Number of clean detected \"encounters\" is: 6\n",
      "Number of detected aggressive bouts is: 1\n",
      "1.0 \n",
      "\n",
      "video_2017-09-21T15_57_23_arena2\n",
      "Number of aggressive bouts is: 12\n",
      "Number of clean detected \"encounters\" is: 15\n",
      "Number of detected aggressive bouts is: 11\n",
      "0.9166666666666666 \n",
      "\n",
      "video_2017-09-26T13_40_19_arena1\n",
      "No aggression for this experiment\n",
      "\n",
      "video_2017-09-28T13_36_06_arena4\n",
      "No aggression for this experiment\n",
      "\n",
      "video_2017-09-28T14_44_01_arena3\n",
      "Number of aggressive bouts is: 3\n",
      "Number of clean detected \"encounters\" is: 24\n",
      "Number of detected aggressive bouts is: 3\n",
      "1.0 \n",
      "\n",
      "video_2017-09-28T15_55_49_arena3\n",
      "No aggression for this experiment\n",
      "\n",
      "video_2017-10-12T15_50_43_arena2\n",
      "No aggression for this experiment\n",
      "\n",
      "video_2017-10-13T16_06_33_arena2\n",
      "No aggression for this experiment\n",
      "\n",
      "video_2017-10-18T15_19_17_arena3\n",
      "No aggression for this experiment\n",
      "\n",
      "video_2017-10-19T13_50_56_arena2\n",
      "No aggression for this experiment\n",
      "\n",
      "video_2017-10-20T13_21_06_arena2\n",
      "Number of aggressive bouts is: 4\n",
      "Number of clean detected \"encounters\" is: 13\n",
      "Number of detected aggressive bouts is: 3\n",
      "0.75 \n",
      "\n",
      "video_2017-10-20T15_44_09_arena2\n",
      "No aggression for this experiment\n",
      "\n",
      "video_2017-10-24T16_13_35_arena4\n",
      "Number of aggressive bouts is: 1\n",
      "Number of clean detected \"encounters\" is: 10\n",
      "Number of detected aggressive bouts is: 1\n",
      "1.0 \n",
      "\n",
      "video_2017-10-25T14_55_12_arena1\n",
      "No aggression for this experiment\n",
      "\n",
      "video_2017-11-02T13_37_48_arena3\n",
      "No aggression for this experiment\n",
      "\n",
      "video_2017-11-02T14_48_28_arena4\n",
      "Number of aggressive bouts is: 1\n",
      "Number of clean detected \"encounters\" is: 15\n",
      "Number of detected aggressive bouts is: 1\n",
      "1.0 \n",
      "\n",
      "video_2017-11-02T16_11_06_arena3\n",
      "No aggression for this experiment\n",
      "\n",
      "video_2017-11-03T14_54_45_arena1\n",
      "No aggression for this experiment\n",
      "\n",
      "video_2017-11-03T16_20_50_arena4\n",
      "No aggression for this experiment\n",
      "\n",
      "video_2017-12-20T12_58_51_arena4\n",
      "Number of aggressive bouts is: 2\n",
      "Number of clean detected \"encounters\" is: 15\n",
      "Number of detected aggressive bouts is: 2\n",
      "1.0 \n",
      "\n",
      "video_2017-12-20T14_01_01_arena3\n",
      "Number of aggressive bouts is: 3\n",
      "Number of clean detected \"encounters\" is: 17\n",
      "Number of detected aggressive bouts is: 2\n",
      "0.6666666666666666 \n",
      "\n"
     ]
    }
   ],
   "source": [
    "# Initialize empty data structures to store data.\n",
    "encounters_df = pd.DataFrame()\n",
    "\n",
    "flags = {condition: {} for condition in condition_order}\n",
    "clean_dict = {condition: {} for condition in condition_order}\n",
    "intersection_fractions = {condition: {} for condition in condition_order}\n",
    "\n",
    "# Start a counter to use as the index for our temporary dataframes in the loop.\n",
    "n = 0\n",
    "for condition in condition_order:\n",
    "    \n",
    "    print(condition, '\\n')\n",
    "    \n",
    "    for experiment_path in experiments[condition]:\n",
    "\n",
    "        experiment = os.path.basename(experiment_path)\n",
    "\n",
    "        # Fetch tracking data.\n",
    "        control = True if condition == 'virgin_virgin' else False\n",
    "        aggression_df, _, copulation_interval, aggression_timepoints = helpers.process_track_data(experiment_path,\n",
    "                                                                                                  trackfeat_columns=['dist_to_other'],\n",
    "                                                                                                  is_control=control,\n",
    "                                                                                                  fly_id=2,\n",
    "                                                                                                  include_aggression_only=False\n",
    "                                                                                                 )\n",
    "\n",
    "        # Keep only frames within copulation time.\n",
    "        sliced_aggression = aggression_df.loc[copulation_interval[0]:copulation_interval[0]+(5*60*FPS)]\n",
    "        aggression_timepoints = [event for event in aggression_timepoints if event[0] < copulation_interval[0]+(5*60*FPS)]\n",
    "        raw = []\n",
    "        clean = []\n",
    "\n",
    "        # Apply threshold(s).\n",
    "        proximity = sliced_aggression['dist_to_other'].values < 4\n",
    "\n",
    "        # Detect event start and end, and package them into a list of tuples.\n",
    "        if proximity[0] == True:\n",
    "            proximity = np.insert(proximity, 0, False)\n",
    "        proximity_onset = proximity[:-1] < proximity[1:]\n",
    "        proximity_offset = proximity[:-1] > proximity[1:]\n",
    "        onset_indices = np.where(proximity_onset==True)[0] + copulation_interval[0]\n",
    "        offset_indices = np.where(proximity_offset==True)[0] + copulation_interval[0]\n",
    "\n",
    "        raw_events = list(zip(onset_indices, offset_indices))\n",
    "        if len(raw_events) > 0:\n",
    "\n",
    "            # Combine events that are very close to each other into a single event.\n",
    "            clean_events = helpers.stitch_events(raw_events, suppress=True)\n",
    "\n",
    "            assert len(clean_events) <= len(raw_events), 'Stitched events list is bigger than original list: {} vs {}'.format(len(clean_events), len(raw_events))\n",
    "\n",
    "            clean_dict[condition][experiment] = clean_events\n",
    "\n",
    "            # Check for abnormally long \"encounters\", which might be indicative of tracking issues.\n",
    "            clean_events_durations = [event[1] - event[0] for event in clean_events]\n",
    "            long_durations = np.where(np.array(clean_events_durations) >= 3600)[0] # filter for bouts that are 1 minute or longer.\n",
    "            if len(long_durations) != 0:\n",
    "                flags[condition][experiment] = [clean_events[index][0] for index in long_durations]\n",
    "\n",
    "            # Get accuracy for our detector.\n",
    "            if len(aggression_timepoints) > 0:\n",
    "                nd_aggression, _, accuracy, intersect = helpers.calc_detection_accuracy(aggression_timepoints, clean_events, threshold=0.25, use_thresh=True)\n",
    "\n",
    "                intersection_fractions[condition][experiment] = intersect\n",
    "                n_bout_overlaps = len(intersect)\n",
    "                print(accuracy, '\\n')\n",
    "\n",
    "            else:\n",
    "                n_bout_overlaps = 0\n",
    "                print('No aggression for this experiment\\n')\n",
    "        \n",
    "        # In case a given experiment has no proximity encounters whatsoever.\n",
    "        else:\n",
    "            clean_dict[condition][experiment] = []\n",
    "            clean_events_durations = []\n",
    "            nd_aggression = 0\n",
    "            accuracy = 0\n",
    "            intersect = []\n",
    "            intersection_fractions[condition][experiment] = 0\n",
    "            n_bout_overlaps = 0\n",
    "            print('No encounters for this experiment\\n')\n",
    "        \n",
    "        # From the extracted data, calculate all the variables we need.\n",
    "        copulation_duration = np.diff(copulation_interval)[0]\n",
    "        aggression_total_frame_duration = sum([np.diff(timepoint)[0] for timepoint in aggression_timepoints])\n",
    "        n_encounter_frames = sum(clean_events_durations)\n",
    "        encounters_frame_ratio = n_encounter_frames / copulation_duration\n",
    "        aggression_frame_ratio = aggression_total_frame_duration / n_encounter_frames if n_encounter_frames > 0 else 0\n",
    "\n",
    "        # Create a one-row pandas DataFrame to store all the information we've calculated.\n",
    "        temp_df = pd.DataFrame(data={'condition': condition,\n",
    "                                     'experiment': experiment,\n",
    "                                     'copulation_duration': copulation_duration,\n",
    "                                     'aggression_duration': aggression_total_frame_duration,\n",
    "                                     'n_bouts_aggression': len(aggression_timepoints),\n",
    "                                     'has_aggression': True if len(aggression_timepoints) > 0 else False,\n",
    "                                     'n_encounters': len(clean_events),\n",
    "                                     'fraction_aggressive_encounters': nd_aggression / len(clean_events) if len(aggression_timepoints) > 0 else 0,\n",
    "                                     'encounters_frame_ratio': encounters_frame_ratio,\n",
    "                                     'aggression_frame_ratio': aggression_frame_ratio,\n",
    "                                     'n_bout_overlaps': n_bout_overlaps\n",
    "                                    },\n",
    "                               index=[n]\n",
    "                              )\n",
    "        \n",
    "        # Store the current experiment's data into our global DataFrame.\n",
    "        encounters_df = pd.concat([encounters_df, temp_df], axis=0)\n",
    "        \n",
    "        # Increment our counter.\n",
    "        n += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>condition</th>\n",
       "      <th>experiment</th>\n",
       "      <th>copulation_duration</th>\n",
       "      <th>aggression_duration</th>\n",
       "      <th>n_bouts_aggression</th>\n",
       "      <th>has_aggression</th>\n",
       "      <th>n_encounters</th>\n",
       "      <th>fraction_aggressive_encounters</th>\n",
       "      <th>encounters_frame_ratio</th>\n",
       "      <th>aggression_frame_ratio</th>\n",
       "      <th>n_bout_overlaps</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>virgin_virgin</td>\n",
       "      <td>video_2017-09-05T13_28_41_arena4</td>\n",
       "      <td>42083</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>False</td>\n",
       "      <td>14</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.024761</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>virgin_virgin</td>\n",
       "      <td>video_2017-09-05T14_34_55_arena2</td>\n",
       "      <td>54966</td>\n",
       "      <td>377</td>\n",
       "      <td>6</td>\n",
       "      <td>True</td>\n",
       "      <td>11</td>\n",
       "      <td>0.545455</td>\n",
       "      <td>0.049740</td>\n",
       "      <td>0.137893</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>virgin_virgin</td>\n",
       "      <td>video_2017-09-06T13_42_13_arena1</td>\n",
       "      <td>37771</td>\n",
       "      <td>202</td>\n",
       "      <td>3</td>\n",
       "      <td>True</td>\n",
       "      <td>14</td>\n",
       "      <td>0.214286</td>\n",
       "      <td>0.087951</td>\n",
       "      <td>0.060807</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>virgin_virgin</td>\n",
       "      <td>video_2017-09-06T14_45_32_arena3</td>\n",
       "      <td>51519</td>\n",
       "      <td>770</td>\n",
       "      <td>11</td>\n",
       "      <td>True</td>\n",
       "      <td>10</td>\n",
       "      <td>1.100000</td>\n",
       "      <td>0.080495</td>\n",
       "      <td>0.185676</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>virgin_virgin</td>\n",
       "      <td>video_2017-09-07T14_37_38_arena3</td>\n",
       "      <td>46945</td>\n",
       "      <td>579</td>\n",
       "      <td>7</td>\n",
       "      <td>True</td>\n",
       "      <td>3</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.009138</td>\n",
       "      <td>1.349650</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       condition                        experiment  copulation_duration  \\\n",
       "0  virgin_virgin  video_2017-09-05T13_28_41_arena4                42083   \n",
       "1  virgin_virgin  video_2017-09-05T14_34_55_arena2                54966   \n",
       "2  virgin_virgin  video_2017-09-06T13_42_13_arena1                37771   \n",
       "3  virgin_virgin  video_2017-09-06T14_45_32_arena3                51519   \n",
       "4  virgin_virgin  video_2017-09-07T14_37_38_arena3                46945   \n",
       "\n",
       "   aggression_duration  n_bouts_aggression  has_aggression  n_encounters  \\\n",
       "0                    0                   0           False            14   \n",
       "1                  377                   6            True            11   \n",
       "2                  202                   3            True            14   \n",
       "3                  770                  11            True            10   \n",
       "4                  579                   7            True             3   \n",
       "\n",
       "   fraction_aggressive_encounters  encounters_frame_ratio  \\\n",
       "0                        0.000000                0.024761   \n",
       "1                        0.545455                0.049740   \n",
       "2                        0.214286                0.087951   \n",
       "3                        1.100000                0.080495   \n",
       "4                        0.000000                0.009138   \n",
       "\n",
       "   aggression_frame_ratio  n_bout_overlaps  \n",
       "0                0.000000                0  \n",
       "1                0.137893                6  \n",
       "2                0.060807                3  \n",
       "3                0.185676               11  \n",
       "4                1.349650                0  "
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "encounters_df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## What fraction of \"encounters\" during copulation are aggressive?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHkAAAEgCAYA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HNALWOnawj4MWFPr/QWuvzuB5bVeV0dFvQI4T0QmAyMxy1i9eb5PcYxsCAZmqOpvAUQkmlrfTb36uqKB+5dhcvliYBHHjnl7fL6vCeg6uRaLgUkikigmqz0L/M7KjSKSgJmCvA+T4y/AGLVZnt8cOEYGVDUTMyf8GbARY6THLN57GHjJdd/3mFjdUSLSptY1TX5+c+CMeAUATk4OABwjBwCOkQMAx8gBgGPkAMAxcgDgGDkAcIwcADhGDgAcIwcA/w+Ay6ewfJm18AAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 90x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Initialize figure.\n",
    "n_conditions = encounters_df['condition'].nunique()\n",
    "figure, axis = plt.subplots(figsize=(1.25*n_conditions, 4))\n",
    "\n",
    "# Draw the boxplot.\n",
    "sns.boxplot(x='condition',\n",
    "            y='fraction_aggressive_encounters',\n",
    "            data=encounters_df,\n",
    "            palette=['steelblue'],\n",
    "            width=0.6,\n",
    "            showfliers=False,\n",
    "            boxprops={'edgecolor': INK},\n",
    "            capprops={'color': INK},\n",
    "            medianprops={'color': INK},\n",
    "            whiskerprops={'color': INK}\n",
    "           )\n",
    "\n",
    "# Draw the swarmplot.\n",
    "sns.swarmplot(x='condition',\n",
    "              y='fraction_aggressive_encounters',\n",
    "              data=encounters_df,\n",
    "              palette=['steelblue'],\n",
    "              linewidth=0.75,\n",
    "              edgecolor=INK\n",
    "             )\n",
    "\n",
    "# Figure and axes formatting.\n",
    "axis.set_xlabel('')\n",
    "axis.set_xticklabels([''])\n",
    "axis.set_ylabel('Aggressive Encounters (%)')\n",
    "axis.set_ylim(0, 0.5)\n",
    "axis.set_yticks(np.arange(0, 0.5+0.1, 0.1))\n",
    "axis.set_yticklabels([int(y*100) for y in axis.get_yticks()])\n",
    "\n",
    "# Table definition.\n",
    "row1 = [str(encounters_df.query('condition==\"'+condition+'\"').shape[0]) for condition in condition_order]\n",
    "row2 = ['virgin\\nfemale'] \n",
    "cell_text = np.array([row1, row2])\n",
    "\n",
    "row_labels = ['n =', '']\n",
    "summary_table = axis.table(cellText= cell_text,\n",
    "                           cellLoc='center',\n",
    "                           rowLabels=row_labels,\n",
    "                           rowLoc='center',\n",
    "                           colLoc='center'\n",
    "                          )\n",
    "\n",
    "summary_table.auto_set_font_size(False)\n",
    "summary_table.set_fontsize(11)\n",
    "\n",
    "properties = summary_table.properties()\n",
    "table_cells = properties['children']\n",
    "for cell in table_cells:\n",
    "    cell.set_height(0.12)\n",
    "    cell.set_alpha(0)\n",
    "\n",
    "# Saving parameters.\n",
    "filename = 'percentage_aggressive_encounters'\n",
    "plt.savefig(os.path.join(savepath, filename))\n",
    "\n",
    "plt.show()\n",
    "plt.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHkAAAEgCAYAAACQDNzCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nO2dd3hUZfbHPyc9IY0AIUASILQAoSMiqDR7wcUVrIuuunbXtezPXddVLKuuq6vrFl0L9rJYaAIqolRFRCACikgPIXRI7zm/P95JTEJmcidkcifO/TzPfTL3nXvvfDNn3n7e84qq4vDzJshuAQ6+xzFyAOAYOQBwjBwAOEYOABwjBwAtYmQReVJEdonIOtfxPxEJFpGnRWSTiGwRkRtaQksgEtJCnzMKuERVv6hOEJGbgN5ABhADfCkia1R1VQtpChh8npNFJBwYAvyfiKwXkfdFJBWYBLysqhWqegR4B7jC13oCkZYorjsDnwH3AgOBlcBsIBXIqnXdbiC5BfQEHD43sqpuV9VzVHWDmjHUJ4AeQBpQe0xVgEp3zxGRa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faqyISJyKzXZ6bc1270HYTkatE5BXX/TtE5CHXfRtFZJgd/5dj5Lq8DlwK4FqEF4GZP66mN2bv6Csxjns/qGp/4AFggJtnHlLVEcBzwD2+Eu4Jx8h1mQecJCIxGGO/Ue/9H1Q11/X6dMyPAlVdDaynYT5y/d1APV+2lsIxci1UtQzjNToRmALU3za9uNbrSqx9f9X+bMf4srUUjpGP5XXgTkwxu9PDdZ8ClwGIyAAgA2NIv8Px8aqHqq4QkTjg2UYufQh4WUS+xayr3kvdnO43OF2oJuIKhbHd9aNIBZYAPVy+5H6Fk5ObzibgOREJBqqA6/3RwODk5IDAaXgFAAFvZBGZLiLbRORSHzz7FRG5qrmf6y1OnQxXYdY4ldktxFcEdE4WkTmYAYpVIjJVRNa4VlC+JCIRrmv2ishzrrHpBSIyWUSWich218J0RGSMiCx33b9NRC5o4LMafH6L4C6yaqAcmAGM/sAyTI4GeBS4t9b7F7hefw685Xp9JTDT9fo9IN31ejyw3vX6FUxJ4fb5LXE4xbVhHNALWOnawj4MWFPr/QWuvzuB5bVeV0dFvQI4T0QmAyMxy1i9eb5PcYxsCAZmqOpvAUQkmlrfTb36uqKB+5dhcvliYBHHjnl7fL6vCeg6uRaLgUkikigmqz0L/M7KjSKSgJmCvA+T4y/AGLVZnt8cOEYGVDUTMyf8GbARY6THLN57GHjJdd/3mFjdUSLSptY1TX5+c+CMeAUATk4OABwjBwCOkQMAx8gBgGPkAMAxcgDgGDkAcIwcADhGDgAcIwcA/w+Ay6ewfJm18AAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 90x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Initialize figure.\n",
    "n_conditions = encounters_df['condition'].nunique()\n",
    "figure, axis = plt.subplots(figsize=(1.25*n_conditions, 4))\n",
    "\n",
    "# Draw the boxplot.\n",
    "sns.boxplot(x='condition',\n",
    "            y='fraction_aggressive_encounters',\n",
    "            data=encounters_df,\n",
    "            palette=['steelblue'],\n",
    "            width=0.6,\n",
    "            showfliers=False,\n",
    "            boxprops={'edgecolor': INK},\n",
    "            capprops={'color': INK},\n",
    "            medianprops={'color': INK},\n",
    "            whiskerprops={'color': INK}\n",
    "           )\n",
    "\n",
    "# Draw the swarmplot.\n",
    "sns.swarmplot(x='condition',\n",
    "              y='fraction_aggressive_encounters',\n",
    "              data=encounters_df,\n",
    "              palette=['steelblue'],\n",
    "              linewidth=0.75,\n",
    "              edgecolor=INK\n",
    "             )\n",
    "\n",
    "# Figure and axes formatting.\n",
    "axis.set_xlabel('')\n",
    "axis.set_xticklabels([''])\n",
    "axis.set_ylabel('Aggressive Encounters (%)')\n",
    "axis.set_ylim(0, 0.5)\n",
    "axis.set_yticks(np.arange(0, 0.5+0.1, 0.1))\n",
    "axis.set_yticklabels([int(y*100) for y in axis.get_yticks()])\n",
    "\n",
    "# Table definition.\n",
    "row1 = [str(encounters_df.query('condition==\"'+condition+'\"').shape[0]) for condition in condition_order]\n",
    "row2 = ['virgin\\nfemale'] \n",
    "cell_text = np.array([row1, row2])\n",
    "\n",
    "row_labels = ['n =', '']\n",
    "summary_table = axis.table(cellText= cell_text,\n",
    "                           cellLoc='center',\n",
    "                           rowLabels=row_labels,\n",
    "                           rowLoc='center',\n",
    "                           colLoc='center'\n",
    "                          )\n",
    "\n",
    "summary_table.auto_set_font_size(False)\n",
    "summary_table.set_fontsize(11)\n",
    "\n",
    "properties = summary_table.properties()\n",
    "table_cells = properties['children']\n",
    "for cell in table_cells:\n",
    "    cell.set_height(0.12)\n",
    "    cell.set_alpha(0)\n",
    "\n",
    "# Saving parameters.\n",
    "filename = 'percentage_aggressive_encounters'\n",
    "plt.savefig(os.path.join(savepath, filename))\n",
    "\n",
    "plt.show()\n",
    "plt.close()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## How does the percentage of aggressive encounters vary across copulation time?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "virgin_virgin \n",
      "\n",
      "video_2017-09-05T13_28_41_arena4\n",
      "Number of aggressive bouts is: 1\n",
      "Number of clean detected \"encounters\" is: 30\n",
      "Number of detected aggressive bouts is: 1\n",
      "video_2017-09-05T14_34_55_arena2\n",
      "Number of aggressive bouts is: 10\n",
      "Number of clean detected \"encounters\" is: 26\n",
      "Number of detected aggressive bouts is: 10\n",
      "video_2017-09-06T13_42_13_arena1\n",
      "Number of aggressive bouts is: 6\n",
      "Number of clean detected \"encounters\" is: 31\n",
      "Number of detected aggressive bouts is: 6\n",
      "video_2017-09-06T14_45_32_arena3\n",
      "Number of aggressive bouts is: 13\n",
      "Number of clean detected \"encounters\" is: 30\n",
      "Number of detected aggressive bouts is: 12\n",
      "video_2017-09-07T14_37_38_arena3\n",
      "Number of aggressive bouts is: 7\n",
      "Number of clean detected \"encounters\" is: 22\n",
      "Number of detected aggressive bouts is: 7\n",
      "video_2017-09-07T14_37_38_arena4\n",
      "Number of aggressive bouts is: 5\n",
      "Number of clean detected \"encounters\" is: 29\n",
      "Number of detected aggressive bouts is: 5\n",
      "video_2017-09-08T13_26_13_arena3\n",
      "Number of aggressive bouts is: 12\n",
      "Number of clean detected \"encounters\" is: 56\n",
      "Number of detected aggressive bouts is: 12\n",
      "video_2017-09-12T13_30_06_arena4\n",
      "Number of aggressive bouts is: 5\n",
      "Number of clean detected \"encounters\" is: 20\n",
      "Number of detected aggressive bouts is: 5\n",
      "video_2017-09-12T14_36_55_arena3\n",
      "video_2017-09-12T16_18_15_arena4\n",
      "Number of aggressive bouts is: 3\n",
      "Number of clean detected \"encounters\" is: 24\n",
      "Number of detected aggressive bouts is: 3\n",
      "video_2017-09-13T14_34_18_arena2\n",
      "Number of aggressive bouts is: 4\n",
      "Number of clean detected \"encounters\" is: 48\n",
      "Number of detected aggressive bouts is: 4\n",
      "video_2017-09-20T13_43_53_arena3\n",
      "video_2017-09-20T14_48_55_arena2\n",
      "Number of aggressive bouts is: 2\n",
      "Number of clean detected \"encounters\" is: 25\n",
      "Number of detected aggressive bouts is: 2\n",
      "video_2017-09-21T13_38_55_arena4\n",
      "Number of aggressive bouts is: 3\n",
      "Number of clean detected \"encounters\" is: 24\n",
      "Number of detected aggressive bouts is: 3\n",
      "video_2017-09-21T15_57_23_arena2\n",
      "Number of aggressive bouts is: 19\n",
      "Number of clean detected \"encounters\" is: 42\n",
      "Number of detected aggressive bouts is: 18\n",
      "video_2017-09-26T13_40_19_arena1\n",
      "Number of aggressive bouts is: 3\n",
      "Number of clean detected \"encounters\" is: 32\n",
      "Number of detected aggressive bouts is: 3\n",
      "video_2017-09-28T13_36_06_arena4\n",
      "video_2017-09-28T14_44_01_arena3\n",
      "Number of aggressive bouts is: 3\n",
      "Number of clean detected \"encounters\" is: 57\n",
      "Number of detected aggressive bouts is: 3\n",
      "video_2017-09-28T15_55_49_arena3\n",
      "video_2017-10-12T15_50_43_arena2\n",
      "video_2017-10-13T16_06_33_arena2\n",
      "video_2017-10-18T15_19_17_arena3\n",
      "Number of aggressive bouts is: 3\n",
      "Number of clean detected \"encounters\" is: 40\n",
      "Number of detected aggressive bouts is: 3\n",
      "video_2017-10-19T13_50_56_arena2\n",
      "video_2017-10-20T13_21_06_arena2\n",
      "Number of aggressive bouts is: 6\n",
      "Number of clean detected \"encounters\" is: 56\n",
      "Number of detected aggressive bouts is: 5\n",
      "video_2017-10-20T15_44_09_arena2\n",
      "Number of aggressive bouts is: 1\n",
      "Number of clean detected \"encounters\" is: 47\n",
      "Number of detected aggressive bouts is: 1\n",
      "video_2017-10-24T16_13_35_arena4\n",
      "Number of aggressive bouts is: 2\n",
      "Number of clean detected \"encounters\" is: 28\n",
      "Number of detected aggressive bouts is: 2\n",
      "video_2017-10-25T14_55_12_arena1\n",
      "Number of aggressive bouts is: 9\n",
      "Number of clean detected \"encounters\" is: 21\n",
      "Number of detected aggressive bouts is: 9\n",
      "video_2017-11-02T13_37_48_arena3\n",
      "Number of aggressive bouts is: 8\n",
      "Number of clean detected \"encounters\" is: 22\n",
      "Number of detected aggressive bouts is: 8\n",
      "video_2017-11-02T14_48_28_arena4\n",
      "Number of aggressive bouts is: 2\n",
      "Number of clean detected \"encounters\" is: 32\n",
      "Number of detected aggressive bouts is: 2\n",
      "video_2017-11-02T16_11_06_arena3\n",
      "Number of aggressive bouts is: 1\n",
      "Number of clean detected \"encounters\" is: 28\n",
      "Number of detected aggressive bouts is: 1\n",
      "video_2017-11-03T14_54_45_arena1\n",
      "video_2017-11-03T16_20_50_arena4\n",
      "Number of aggressive bouts is: 1\n",
      "Number of clean detected \"encounters\" is: 62\n",
      "Number of detected aggressive bouts is: 1\n",
      "video_2017-12-20T12_58_51_arena4\n",
      "Number of aggressive bouts is: 2\n",
      "Number of clean detected \"encounters\" is: 34\n",
      "Number of detected aggressive bouts is: 2\n",
      "video_2017-12-20T14_01_01_arena3\n",
      "Number of aggressive bouts is: 3\n",
      "Number of clean detected \"encounters\" is: 37\n",
      "Number of detected aggressive bouts is: 3\n"
     ]
    }
   ],
   "source": [
    "encounters_timing = {condition: [] for condition in condition_order}\n",
    "aggressive_encounters_timing = {condition: [] for condition in condition_order}\n",
    "\n",
    "for condition in condition_order:\n",
    "    \n",
    "    print(condition, '\\n')\n",
    "    \n",
    "    for experiment_path in experiments[condition]:\n",
    "\n",
    "        experiment = os.path.basename(experiment_path)\n",
    "\n",
    "        # Fetch tracking data.\n",
    "        control = True if condition == 'virgin_virgin' else False\n",
    "        aggression_df, mating_df, copulation_interval, aggression_timepoints = helpers_mod.process_track_data(experiment_path,\n",
    "                                                                                                              trackfeat_columns=['dist_to_other'],\n",
    "                                                                                                              is_control=control,\n",
    "                                                                                                              fly_id=2,\n",
    "                                                                                                              include_aggression_only=False\n",
    "                                                                                                             )\n",
    "        \n",
    "        if len(aggression_timepoints) == 0:\n",
    "            continue\n",
    "\n",
    "        # Keep only frames within copulation time.\n",
    "        sliced_aggression = aggression_df.loc[copulation_interval[0]:copulation_interval[1]]\n",
    "\n",
    "        copulation_duration = len(sliced_aggression)\n",
    "\n",
    "        # Apply threshold(s).\n",
    "        proximity = sliced_aggression['dist_to_other'].values < 4\n",
    "\n",
    "        # Detect event start and end, and package them into a list of tuples.\n",
    "        if proximity[0] == True:\n",
    "            proximity = np.insert(proximity, 0, False)\n",
    "        proximity_onset = proximity[:-1] < proximity[1:]\n",
    "        proximity_offset = proximity[:-1] > proximity[1:]\n",
    "        onset_indices = np.where(proximity_onset==True)[0] + copulation_interval[0]\n",
    "        offset_indices = np.where(proximity_offset==True)[0] + copulation_interval[0]\n",
    "\n",
    "        raw_events = list(zip(onset_indices, offset_indices))\n",
    "\n",
    "        if len(raw_events) > 1:\n",
    "\n",
    "            # Combine events that are very close to each other into a single event.\n",
    "            clean_events = helpers_mod.stitch_events(raw_events, suppress=True)\n",
    "\n",
    "            assert len(clean_events) <= len(raw_events), 'Stitched events list is bigger than original list: {} vs {}'.format(len(clean_events), len(raw_events))\n",
    "\n",
    "            # Get accuracy for our detector.\n",
    "            nd_aggression, _, _, _, agg_encounters_start = helpers_mod.calc_detection_accuracy(aggression_timepoints,\n",
    "                                                                                               clean_events,\n",
    "                                                                                               threshold=0.25,\n",
    "                                                                                               use_thresh=True\n",
    "                                                                                              )\n",
    "\n",
    "        # In case a given experiment has no proximity encounters whatsoever.\n",
    "        elif len(raw_events) == 1:\n",
    "\n",
    "            clean_events = raw_events\n",
    "\n",
    "            # Get accuracy for our detector.\n",
    "            nd_aggression, _, _, _, agg_encounters_start = helpers_mod.calc_detection_accuracy(aggression_timepoints,\n",
    "                                                                                               clean_events,\n",
    "                                                                                               threshold=0.25,\n",
    "                                                                                               use_thresh=True\n",
    "                                                                                              )\n",
    "\n",
    "        else:\n",
    "            clean_events = []\n",
    "            nd_aggression = 0\n",
    "            agg_encounters_start = []\n",
    "            print('No encounters for this experiment\\n')\n",
    "            \n",
    "        # From the extracted data, calculate all the variables we need.\n",
    "        encounters_start_frames = [event[0] for event in clean_events]\n",
    "        encounters_start_in_cop = [start - copulation_interval[0] for start in encounters_start_frames]\n",
    "        encounters_start_percent_cop = [round((start / copulation_duration) * 100, 2) for start in encounters_start_in_cop]\n",
    "        [encounters_timing[condition].append(percent) for percent in encounters_start_percent_cop]\n",
    "\n",
    "        aggressive_encounters_start_frames = [event for event in agg_encounters_start]\n",
    "        aggressive_encounters_start_in_cop = [start - copulation_interval[0] for start in aggressive_encounters_start_frames]\n",
    "        aggressive_encounters_start_percent_cop = [round((start / copulation_duration) * 100, 2) for start in aggressive_encounters_start_in_cop]\n",
    "        [aggressive_encounters_timing[condition].append(percent) for percent in aggressive_encounters_start_percent_cop]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## How does the number of encounters overall vary across copulation time?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'virgin_virgin': [9.06,\n",
       "  13.3,\n",
       "  15.02,\n",
       "  16.89,\n",
       "  18.5,\n",
       "  19.83,\n",
       "  21.33,\n",
       "  22.73,\n",
       "  24.42,\n",
       "  26.67,\n",
       "  30.57,\n",
       "  33.24,\n",
       "  37.28,\n",
       "  41.93,\n",
       "  44.57,\n",
       "  46.32,\n",
       "  49.78,\n",
       "  57.62,\n",
       "  58.14,\n",
       "  61.01,\n",
       "  62.82,\n",
       "  65.32,\n",
       "  67.76,\n",
       "  68.5,\n",
       "  74.72,\n",
       "  77.13,\n",
       "  80.28,\n",
       "  82.05,\n",
       "  92.88,\n",
       "  97.7,\n",
       "  0.16,\n",
       "  2.06,\n",
       "  5.9,\n",
       "  7.36,\n",
       "  8.58,\n",
       "  10.5,\n",
       "  11.53,\n",
       "  13.06,\n",
       "  13.44,\n",
       "  19.94,\n",
       "  30.67,\n",
       "  42.87,\n",
       "  50.57,\n",
       "  53.72,\n",
       "  55.34,\n",
       "  59.34,\n",
       "  60.53,\n",
       "  78.19,\n",
       "  79.95,\n",
       "  81.61,\n",
       "  81.99,\n",
       "  86.36,\n",
       "  87.24,\n",
       "  88.71,\n",
       "  90.15,\n",
       "  99.17,\n",
       "  2.09,\n",
       "  7.4,\n",
       "  19.53,\n",
       "  19.98,\n",
       "  29.54,\n",
       "  32.72,\n",
       "  33.34,\n",
       "  34.95,\n",
       "  40.54,\n",
       "  42.54,\n",
       "  44.69,\n",
       "  46.39,\n",
       "  47.05,\n",
       "  47.46,\n",
       "  48.48,\n",
       "  51.11,\n",
       "  52.74,\n",
       "  55.67,\n",
       "  58.23,\n",
       "  60.43,\n",
       "  61.95,\n",
       "  63.38,\n",
       "  63.93,\n",
       "  66.55,\n",
       "  87.32,\n",
       "  90.75,\n",
       "  91.86,\n",
       "  94.49,\n",
       "  95.43,\n",
       "  96.4,\n",
       "  98.02,\n",
       "  1.03,\n",
       "  7.0,\n",
       "  8.37,\n",
       "  9.57,\n",
       "  18.9,\n",
       "  21.43,\n",
       "  23.68,\n",
       "  25.0,\n",
       "  26.9,\n",
       "  28.61,\n",
       "  50.49,\n",
       "  54.23,\n",
       "  57.18,\n",
       "  59.63,\n",
       "  62.15,\n",
       "  63.98,\n",
       "  66.8,\n",
       "  68.79,\n",
       "  70.98,\n",
       "  71.6,\n",
       "  77.14,\n",
       "  79.16,\n",
       "  81.8,\n",
       "  83.95,\n",
       "  85.6,\n",
       "  87.63,\n",
       "  88.44,\n",
       "  89.8,\n",
       "  91.27,\n",
       "  92.63,\n",
       "  15.35,\n",
       "  19.18,\n",
       "  22.73,\n",
       "  26.02,\n",
       "  42.04,\n",
       "  50.64,\n",
       "  55.01,\n",
       "  57.23,\n",
       "  58.65,\n",
       "  61.47,\n",
       "  64.58,\n",
       "  68.0,\n",
       "  71.13,\n",
       "  74.27,\n",
       "  76.42,\n",
       "  82.92,\n",
       "  85.55,\n",
       "  88.79,\n",
       "  91.78,\n",
       "  94.6,\n",
       "  98.2,\n",
       "  98.76,\n",
       "  1.87,\n",
       "  2.5,\n",
       "  8.24,\n",
       "  14.24,\n",
       "  16.61,\n",
       "  16.96,\n",
       "  20.54,\n",
       "  21.97,\n",
       "  29.62,\n",
       "  34.96,\n",
       "  38.29,\n",
       "  39.29,\n",
       "  40.11,\n",
       "  45.02,\n",
       "  46.69,\n",
       "  47.41,\n",
       "  49.94,\n",
       "  54.43,\n",
       "  66.86,\n",
       "  67.26,\n",
       "  67.51,\n",
       "  69.03,\n",
       "  70.6,\n",
       "  72.06,\n",
       "  77.31,\n",
       "  83.15,\n",
       "  90.13,\n",
       "  96.93,\n",
       "  98.55,\n",
       "  3.77,\n",
       "  5.11,\n",
       "  7.77,\n",
       "  9.8,\n",
       "  10.97,\n",
       "  12.04,\n",
       "  15.61,\n",
       "  16.91,\n",
       "  17.74,\n",
       "  18.29,\n",
       "  19.15,\n",
       "  20.64,\n",
       "  22.24,\n",
       "  22.76,\n",
       "  26.48,\n",
       "  27.5,\n",
       "  29.03,\n",
       "  30.03,\n",
       "  30.8,\n",
       "  31.14,\n",
       "  31.44,\n",
       "  31.78,\n",
       "  33.06,\n",
       "  33.86,\n",
       "  34.43,\n",
       "  34.79,\n",
       "  35.68,\n",
       "  36.89,\n",
       "  37.21,\n",
       "  38.44,\n",
       "  40.13,\n",
       "  40.69,\n",
       "  41.9,\n",
       "  43.42,\n",
       "  44.79,\n",
       "  45.66,\n",
       "  47.38,\n",
       "  48.96,\n",
       "  50.06,\n",
       "  53.75,\n",
       "  54.41,\n",
       "  56.35,\n",
       "  58.31,\n",
       "  59.2,\n",
       "  60.91,\n",
       "  65.75,\n",
       "  67.7,\n",
       "  69.25,\n",
       "  74.35,\n",
       "  79.98,\n",
       "  82.2,\n",
       "  87.06,\n",
       "  92.71,\n",
       "  93.49,\n",
       "  94.93,\n",
       "  98.98,\n",
       "  10.68,\n",
       "  13.18,\n",
       "  14.28,\n",
       "  29.84,\n",
       "  31.67,\n",
       "  33.37,\n",
       "  34.4,\n",
       "  37.6,\n",
       "  38.2,\n",
       "  39.8,\n",
       "  47.46,\n",
       "  57.48,\n",
       "  59.9,\n",
       "  62.4,\n",
       "  64.33,\n",
       "  68.66,\n",
       "  70.68,\n",
       "  74.71,\n",
       "  85.77,\n",
       "  86.28,\n",
       "  7.41,\n",
       "  13.36,\n",
       "  15.81,\n",
       "  20.08,\n",
       "  24.89,\n",
       "  26.08,\n",
       "  26.47,\n",
       "  31.11,\n",
       "  33.58,\n",
       "  36.22,\n",
       "  41.96,\n",
       "  44.39,\n",
       "  48.53,\n",
       "  50.61,\n",
       "  53.65,\n",
       "  55.53,\n",
       "  58.69,\n",
       "  60.55,\n",
       "  66.05,\n",
       "  67.84,\n",
       "  72.25,\n",
       "  87.21,\n",
       "  90.79,\n",
       "  95.77,\n",
       "  0.02,\n",
       "  2.54,\n",
       "  2.83,\n",
       "  3.31,\n",
       "  3.67,\n",
       "  4.75,\n",
       "  6.15,\n",
       "  9.47,\n",
       "  14.19,\n",
       "  14.63,\n",
       "  14.91,\n",
       "  16.11,\n",
       "  16.33,\n",
       "  16.98,\n",
       "  17.82,\n",
       "  20.6,\n",
       "  22.62,\n",
       "  25.29,\n",
       "  25.72,\n",
       "  30.08,\n",
       "  31.19,\n",
       "  32.66,\n",
       "  33.36,\n",
       "  38.01,\n",
       "  39.33,\n",
       "  40.67,\n",
       "  44.53,\n",
       "  47.32,\n",
       "  50.82,\n",
       "  55.82,\n",
       "  56.51,\n",
       "  57.64,\n",
       "  57.8,\n",
       "  59.08,\n",
       "  59.9,\n",
       "  61.07,\n",
       "  62.23,\n",
       "  64.69,\n",
       "  65.81,\n",
       "  66.97,\n",
       "  68.33,\n",
       "  70.39,\n",
       "  70.9,\n",
       "  74.05,\n",
       "  75.07,\n",
       "  76.22,\n",
       "  92.64,\n",
       "  97.93,\n",
       "  13.94,\n",
       "  16.23,\n",
       "  18.22,\n",
       "  21.98,\n",
       "  24.78,\n",
       "  35.66,\n",
       "  38.47,\n",
       "  41.76,\n",
       "  44.38,\n",
       "  47.79,\n",
       "  50.33,\n",
       "  53.0,\n",
       "  54.07,\n",
       "  56.27,\n",
       "  59.08,\n",
       "  62.01,\n",
       "  63.28,\n",
       "  64.7,\n",
       "  68.57,\n",
       "  70.98,\n",
       "  71.57,\n",
       "  80.28,\n",
       "  95.34,\n",
       "  96.27,\n",
       "  99.94,\n",
       "  0.17,\n",
       "  1.81,\n",
       "  6.72,\n",
       "  7.57,\n",
       "  12.08,\n",
       "  17.82,\n",
       "  30.84,\n",
       "  33.7,\n",
       "  34.73,\n",
       "  45.09,\n",
       "  47.2,\n",
       "  47.69,\n",
       "  50.67,\n",
       "  52.51,\n",
       "  64.51,\n",
       "  67.75,\n",
       "  68.66,\n",
       "  70.4,\n",
       "  88.91,\n",
       "  90.63,\n",
       "  91.97,\n",
       "  92.97,\n",
       "  96.15,\n",
       "  97.31,\n",
       "  0.36,\n",
       "  14.93,\n",
       "  15.46,\n",
       "  17.14,\n",
       "  19.63,\n",
       "  21.98,\n",
       "  22.32,\n",
       "  23.85,\n",
       "  24.51,\n",
       "  27.0,\n",
       "  28.08,\n",
       "  28.91,\n",
       "  30.18,\n",
       "  35.08,\n",
       "  36.28,\n",
       "  37.12,\n",
       "  39.17,\n",
       "  41.64,\n",
       "  45.01,\n",
       "  62.63,\n",
       "  64.16,\n",
       "  66.03,\n",
       "  66.49,\n",
       "  66.81,\n",
       "  67.14,\n",
       "  68.33,\n",
       "  69.64,\n",
       "  71.5,\n",
       "  73.02,\n",
       "  74.51,\n",
       "  76.65,\n",
       "  77.59,\n",
       "  80.36,\n",
       "  85.08,\n",
       "  86.73,\n",
       "  86.94,\n",
       "  88.65,\n",
       "  92.34,\n",
       "  94.0,\n",
       "  94.42,\n",
       "  96.19,\n",
       "  99.97,\n",
       "  0.48,\n",
       "  2.68,\n",
       "  4.02,\n",
       "  5.86,\n",
       "  7.17,\n",
       "  9.16,\n",
       "  11.82,\n",
       "  13.75,\n",
       "  17.17,\n",
       "  18.67,\n",
       "  20.06,\n",
       "  22.88,\n",
       "  25.42,\n",
       "  29.35,\n",
       "  32.89,\n",
       "  37.75,\n",
       "  40.81,\n",
       "  44.88,\n",
       "  51.68,\n",
       "  52.79,\n",
       "  53.0,\n",
       "  58.92,\n",
       "  59.91,\n",
       "  63.28,\n",
       "  69.44,\n",
       "  69.92,\n",
       "  84.11,\n",
       "  89.87,\n",
       "  92.31,\n",
       "  94.08,\n",
       "  96.48,\n",
       "  97.08,\n",
       "  1.53,\n",
       "  3.15,\n",
       "  3.36,\n",
       "  3.85,\n",
       "  6.72,\n",
       "  7.86,\n",
       "  10.32,\n",
       "  11.86,\n",
       "  12.08,\n",
       "  13.32,\n",
       "  14.7,\n",
       "  15.23,\n",
       "  18.33,\n",
       "  19.52,\n",
       "  22.0,\n",
       "  23.13,\n",
       "  24.28,\n",
       "  25.78,\n",
       "  26.85,\n",
       "  28.97,\n",
       "  29.4,\n",
       "  31.23,\n",
       "  32.56,\n",
       "  34.48,\n",
       "  39.45,\n",
       "  41.33,\n",
       "  42.62,\n",
       "  45.36,\n",
       "  46.38,\n",
       "  46.59,\n",
       "  47.45,\n",
       "  51.44,\n",
       "  52.89,\n",
       "  55.41,\n",
       "  56.74,\n",
       "  59.62,\n",
       "  60.35,\n",
       "  61.47,\n",
       "  62.44,\n",
       "  63.89,\n",
       "  65.5,\n",
       "  66.16,\n",
       "  68.45,\n",
       "  70.02,\n",
       "  71.35,\n",
       "  72.25,\n",
       "  74.5,\n",
       "  76.34,\n",
       "  78.96,\n",
       "  80.07,\n",
       "  81.94,\n",
       "  86.8,\n",
       "  90.31,\n",
       "  93.03,\n",
       "  95.54,\n",
       "  96.55,\n",
       "  98.32,\n",
       "  0.07,\n",
       "  5.3,\n",
       "  9.08,\n",
       "  11.85,\n",
       "  12.31,\n",
       "  14.03,\n",
       "  17.56,\n",
       "  23.39,\n",
       "  25.05,\n",
       "  27.76,\n",
       "  29.34,\n",
       "  31.94,\n",
       "  33.61,\n",
       "  36.24,\n",
       "  37.46,\n",
       "  38.81,\n",
       "  39.94,\n",
       "  42.86,\n",
       "  44.75,\n",
       "  50.53,\n",
       "  52.12,\n",
       "  54.81,\n",
       "  56.94,\n",
       "  58.63,\n",
       "  63.4,\n",
       "  64.58,\n",
       "  65.92,\n",
       "  69.45,\n",
       "  71.47,\n",
       "  72.85,\n",
       "  75.67,\n",
       "  80.04,\n",
       "  83.73,\n",
       "  86.48,\n",
       "  87.83,\n",
       "  88.22,\n",
       "  91.79,\n",
       "  93.1,\n",
       "  95.07,\n",
       "  98.04,\n",
       "  2.02,\n",
       "  2.89,\n",
       "  3.91,\n",
       "  6.02,\n",
       "  7.57,\n",
       "  9.08,\n",
       "  10.66,\n",
       "  13.57,\n",
       "  15.03,\n",
       "  17.18,\n",
       "  20.45,\n",
       "  27.8,\n",
       "  28.14,\n",
       "  31.93,\n",
       "  38.52,\n",
       "  39.3,\n",
       "  40.15,\n",
       "  41.04,\n",
       "  41.63,\n",
       "  42.49,\n",
       "  43.68,\n",
       "  44.62,\n",
       "  45.42,\n",
       "  47.1,\n",
       "  47.84,\n",
       "  48.63,\n",
       "  48.93,\n",
       "  50.25,\n",
       "  50.54,\n",
       "  50.95,\n",
       "  53.19,\n",
       "  54.29,\n",
       "  57.28,\n",
       "  58.53,\n",
       "  60.26,\n",
       "  61.45,\n",
       "  62.88,\n",
       "  63.56,\n",
       "  66.58,\n",
       "  70.44,\n",
       "  71.81,\n",
       "  74.11,\n",
       "  75.21,\n",
       "  76.31,\n",
       "  77.09,\n",
       "  82.51,\n",
       "  83.57,\n",
       "  84.54,\n",
       "  85.42,\n",
       "  86.88,\n",
       "  89.84,\n",
       "  91.24,\n",
       "  93.52,\n",
       "  94.53,\n",
       "  97.27,\n",
       "  98.55,\n",
       "  9.42,\n",
       "  11.3,\n",
       "  14.34,\n",
       "  15.69,\n",
       "  16.73,\n",
       "  18.43,\n",
       "  20.56,\n",
       "  21.08,\n",
       "  23.44,\n",
       "  24.41,\n",
       "  26.24,\n",
       "  28.0,\n",
       "  30.19,\n",
       "  31.74,\n",
       "  34.3,\n",
       "  35.25,\n",
       "  37.82,\n",
       "  39.37,\n",
       "  40.53,\n",
       "  41.74,\n",
       "  44.0,\n",
       "  47.0,\n",
       "  48.86,\n",
       "  50.93,\n",
       "  56.08,\n",
       "  57.18,\n",
       "  58.65,\n",
       "  60.75,\n",
       "  62.53,\n",
       "  67.64,\n",
       "  68.67,\n",
       "  72.26,\n",
       "  73.38,\n",
       "  74.94,\n",
       "  79.12,\n",
       "  81.89,\n",
       "  82.7,\n",
       "  84.31,\n",
       "  85.45,\n",
       "  86.53,\n",
       "  87.7,\n",
       "  89.57,\n",
       "  92.24,\n",
       "  94.94,\n",
       "  95.92,\n",
       "  97.8,\n",
       "  99.53,\n",
       "  9.39,\n",
       "  10.93,\n",
       "  15.36,\n",
       "  17.5,\n",
       "  18.43,\n",
       "  19.7,\n",
       "  21.27,\n",
       "  23.68,\n",
       "  24.35,\n",
       "  29.65,\n",
       "  41.24,\n",
       "  44.02,\n",
       "  46.43,\n",
       "  51.43,\n",
       "  53.22,\n",
       "  55.96,\n",
       "  58.85,\n",
       "  60.53,\n",
       "  61.07,\n",
       "  68.7,\n",
       "  71.82,\n",
       "  74.03,\n",
       "  84.15,\n",
       "  89.32,\n",
       "  91.42,\n",
       "  92.28,\n",
       "  96.3,\n",
       "  98.31,\n",
       "  20.9,\n",
       "  23.0,\n",
       "  32.99,\n",
       "  34.73,\n",
       "  38.77,\n",
       "  40.44,\n",
       "  52.46,\n",
       "  62.91,\n",
       "  63.5,\n",
       "  63.81,\n",
       "  65.82,\n",
       "  67.14,\n",
       "  67.39,\n",
       "  67.6,\n",
       "  74.4,\n",
       "  76.96,\n",
       "  78.36,\n",
       "  80.03,\n",
       "  84.44,\n",
       "  85.97,\n",
       "  88.63,\n",
       "  9.42,\n",
       "  19.53,\n",
       "  33.52,\n",
       "  35.78,\n",
       "  36.5,\n",
       "  38.04,\n",
       "  42.07,\n",
       "  53.16,\n",
       "  56.84,\n",
       "  59.25,\n",
       "  59.5,\n",
       "  63.76,\n",
       "  66.22,\n",
       "  70.66,\n",
       "  70.96,\n",
       "  72.37,\n",
       "  75.99,\n",
       "  81.48,\n",
       "  83.38,\n",
       "  84.95,\n",
       "  91.84,\n",
       "  97.52,\n",
       "  1.71,\n",
       "  2.85,\n",
       "  4.62,\n",
       "  9.2,\n",
       "  10.94,\n",
       "  13.26,\n",
       "  13.99,\n",
       "  16.04,\n",
       "  17.17,\n",
       "  18.43,\n",
       "  25.59,\n",
       "  27.41,\n",
       "  28.69,\n",
       "  30.42,\n",
       "  34.69,\n",
       "  37.3,\n",
       "  39.02,\n",
       "  42.73,\n",
       "  45.14,\n",
       "  49.56,\n",
       "  52.99,\n",
       "  55.57,\n",
       "  67.75,\n",
       "  71.82,\n",
       "  74.46,\n",
       "  82.0,\n",
       "  84.8,\n",
       "  86.46,\n",
       "  92.66,\n",
       "  95.0,\n",
       "  98.09,\n",
       "  99.3,\n",
       "  0.72,\n",
       "  6.12,\n",
       "  15.44,\n",
       "  21.81,\n",
       "  24.37,\n",
       "  25.99,\n",
       "  28.21,\n",
       "  32.01,\n",
       "  35.99,\n",
       "  38.51,\n",
       "  40.37,\n",
       "  42.49,\n",
       "  44.3,\n",
       "  47.02,\n",
       "  57.59,\n",
       "  59.95,\n",
       "  61.84,\n",
       "  63.0,\n",
       "  65.4,\n",
       "  66.94,\n",
       "  70.92,\n",
       "  73.35,\n",
       "  76.58,\n",
       "  81.8,\n",
       "  84.72,\n",
       "  85.6,\n",
       "  87.94,\n",
       "  92.97,\n",
       "  4.08,\n",
       "  5.6,\n",
       "  6.68,\n",
       "  8.05,\n",
       "  9.59,\n",
       "  10.72,\n",
       "  12.22,\n",
       "  13.59,\n",
       "  16.6,\n",
       "  17.82,\n",
       "  19.04,\n",
       "  21.53,\n",
       "  22.07,\n",
       "  25.52,\n",
       "  26.05,\n",
       "  27.99,\n",
       "  28.39,\n",
       "  28.79,\n",
       "  30.62,\n",
       "  32.17,\n",
       "  33.7,\n",
       "  34.79,\n",
       "  36.06,\n",
       "  37.17,\n",
       "  38.64,\n",
       "  39.78,\n",
       "  41.29,\n",
       "  42.44,\n",
       "  43.58,\n",
       "  45.18,\n",
       "  46.91,\n",
       "  48.16,\n",
       "  49.57,\n",
       "  53.37,\n",
       "  55.09,\n",
       "  56.39,\n",
       "  57.63,\n",
       "  59.38,\n",
       "  60.97,\n",
       "  62.38,\n",
       "  63.99,\n",
       "  66.02,\n",
       "  68.44,\n",
       "  70.29,\n",
       "  71.88,\n",
       "  73.04,\n",
       "  74.5,\n",
       "  75.89,\n",
       "  78.16,\n",
       "  79.97,\n",
       "  84.02,\n",
       "  85.83,\n",
       "  88.44,\n",
       "  90.0,\n",
       "  91.43,\n",
       "  93.19,\n",
       "  94.65,\n",
       "  95.41,\n",
       "  96.19,\n",
       "  97.37,\n",
       "  98.97,\n",
       "  99.12,\n",
       "  1.84,\n",
       "  6.62,\n",
       "  10.46,\n",
       "  12.93,\n",
       "  14.84,\n",
       "  25.34,\n",
       "  26.97,\n",
       "  29.57,\n",
       "  31.43,\n",
       "  31.89,\n",
       "  34.75,\n",
       "  36.72,\n",
       "  39.5,\n",
       "  41.85,\n",
       "  44.48,\n",
       "  46.29,\n",
       "  49.0,\n",
       "  51.66,\n",
       "  52.68,\n",
       "  54.35,\n",
       "  59.51,\n",
       "  62.93,\n",
       "  71.03,\n",
       "  73.68,\n",
       "  76.63,\n",
       "  77.93,\n",
       "  81.23,\n",
       "  82.45,\n",
       "  84.23,\n",
       "  86.24,\n",
       "  88.07,\n",
       "  92.41,\n",
       "  96.31,\n",
       "  99.54,\n",
       "  0.0,\n",
       "  6.12,\n",
       "  7.56,\n",
       "  16.38,\n",
       "  17.06,\n",
       "  20.11,\n",
       "  21.46,\n",
       "  24.03,\n",
       "  27.56,\n",
       "  28.67,\n",
       "  30.35,\n",
       "  33.8,\n",
       "  39.56,\n",
       "  40.16,\n",
       "  43.65,\n",
       "  44.31,\n",
       "  45.85,\n",
       "  47.95,\n",
       "  48.93,\n",
       "  50.71,\n",
       "  51.86,\n",
       "  53.7,\n",
       "  56.67,\n",
       "  60.19,\n",
       "  65.09,\n",
       "  66.54,\n",
       "  66.79,\n",
       "  69.99,\n",
       "  70.83,\n",
       "  71.02,\n",
       "  73.71,\n",
       "  77.26,\n",
       "  85.28,\n",
       "  91.7,\n",
       "  93.98,\n",
       "  96.76,\n",
       "  97.39]}"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "encounters_timing"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZsAAAEXCAYAAAB76ulbAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nO3df1yN9/8/8Mepk6R6V8iKQ6neIv0kUtxUvBkNNb/mho0wLXyMWcbG1gx7z6/3Zn7N71m2sLeY342FMUNok6EiRH40ln5Sp17fP/p2vZ1VTug6p06P++3W7ea6zrnO9TyvOufhel2v63UphBACREREMjLSdwFERGT4GDZERCQ7hg0REcmOYUNERLJj2BARkewYNkREJDudhM358+cRFBQEHx8f+Pr64syZMygpKcGUKVPQtm1buLi4YNWqVboohYiI9EAp9w4KCgrQu3dvrFu3DiEhIdi5cydGjBiByZMnIyUlBcnJycjNzYW/vz86dOiAzp07y10SERHpmOxHNvHx8XB2dkZISAgAYMCAAdi6dSvi4uIQHh4OpVIJGxsbDBs2DDExMXKXQ0REeiB72KSkpMDOzg5jx46Fr68vevXqBbVajYyMDLRs2VJ6nkqlws2bN+Uuh4iI9ED2sCkuLsbevXsxfvx4JCYm4v/+7/8QEhKCx48fQ6FQSM8TQ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r164e2bdvC1NQUHh4ecHNzQ1paWqUTw5VvV351NdVtuhqeWR/s2rXrubZ7cgg06V9wcHCFUYHz589Ho0aNqtxm+fLlCA8PR7t27aBSqeDt7S13mRKFEH+b6pOIiKiG6b0bjYiIDB/DhoiIZMewISIi2TFsiIhIdgwbIiKSHcOGiIhkx7AhIiLZMWyIiEh2/w9Bb6ti2z03vAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Set bin edges based on desired bin size.\n",
    "percentage = 5\n",
    "nbins = int(100 / percentage) + 1\n",
    "bins = np.linspace(0, 100, num=nbins)\n",
    "\n",
    "# Plot histogram for each condition.\n",
    "for condition in condition_order:\n",
    "\n",
    "    # Initialize figure.\n",
    "    figure, axis = plt.subplots()\n",
    "    \n",
    "    # Draw the histogram.\n",
    "    sns.distplot(encounters_timing[condition],\n",
    "                 bins=bins,\n",
    "                 kde=False,\n",
    "                 color='steelblue',\n",
    "                 hist_kws={'alpha': 1, 'edgecolor': INK}\n",
    "                )\n",
    "    \n",
    "    # Figure and axes formatting.\n",
    "    axis.set_xlabel('Copulation Time (%)', labelpad=-15)\n",
    "    axis.set_xlim(0, 101)\n",
    "    xticklabels = [int(label) for label in axis.get_xticks()]\n",
    "    xticklabels[0] = '0\\nCopulation\\nStart'\n",
    "    xticklabels[5] = '100\\nCopulation\\nEnd'\n",
    "    axis.set_xticklabels(xticklabels)\n",
    "    axis.tick_params(axis='x', length=5)\n",
    "    axis.set_ylabel('# Encounters')\n",
    "    axis.set_ylim(0, 60)\n",
    "    axis.set_yticks(range(0, 70, 20))\n",
    "    \n",
    "    # Saving paraemetrs.\n",
    "    filename = 'encounters_timing_distribution_during_copulation_histogram_' + condition\n",
    "    plt.savefig(os.path.join(savepath, filename))\n",
    "    \n",
    "    plt.show()\n",
    "    plt.close()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## How does the fraction of aggressive encounter vary across copulation time?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[74.72,\n",
       " 0.16,\n",
       " 13.06,\n",
       " 13.44,\n",
       " 19.94,\n",
       " 19.94,\n",
       " 30.67,\n",
       " 42.87,\n",
       " 79.95,\n",
       " 81.99,\n",
       " 81.99,\n",
       " 29.54,\n",
       " 29.54,\n",
       " 42.54,\n",
       " 87.32,\n",
       " 87.32,\n",
       " 87.32,\n",
       " 7.0,\n",
       " 8.37,\n",
       " 18.9,\n",
       " 18.9,\n",
       " 23.68,\n",
       " 23.68,\n",
       " 23.68,\n",
       " 25.0,\n",
       " 28.61,\n",
       " 28.61,\n",
       " 28.61,\n",
       " 68.79,\n",
       " 26.02,\n",
       " 26.02,\n",
       " 26.02,\n",
       " 26.02,\n",
       " 26.02,\n",
       " 26.02,\n",
       " 26.02,\n",
       " 14.24,\n",
       " 29.62,\n",
       " 29.62,\n",
       " 46.69,\n",
       " 77.31,\n",
       " 15.61,\n",
       " 15.61,\n",
       " 16.91,\n",
       " 20.64,\n",
       " 27.5,\n",
       " 29.03,\n",
       " 30.03,\n",
       " 30.03,\n",
       " 37.21,\n",
       " 79.98,\n",
       " 79.98,\n",
       " 93.49,\n",
       " 34.4,\n",
       " 34.4,\n",
       " 34.4,\n",
       " 39.8,\n",
       " 47.46,\n",
       " 15.81,\n",
       " 15.81,\n",
       " 55.53,\n",
       " 14.91,\n",
       " 14.91,\n",
       " 16.33,\n",
       " 20.6,\n",
       " 68.57,\n",
       " 96.27,\n",
       " 17.82,\n",
       " 30.84,\n",
       " 33.7,\n",
       " 14.93,\n",
       " 15.46,\n",
       " 17.14,\n",
       " 19.63,\n",
       " 19.63,\n",
       " 23.85,\n",
       " 24.51,\n",
       " 28.08,\n",
       " 28.91,\n",
       " 30.18,\n",
       " 36.28,\n",
       " 37.12,\n",
       " 41.64,\n",
       " 45.01,\n",
       " 45.01,\n",
       " 64.16,\n",
       " 64.16,\n",
       " 74.51,\n",
       " 44.88,\n",
       " 51.68,\n",
       " 59.91,\n",
       " 12.08,\n",
       " 34.48,\n",
       " 34.48,\n",
       " 87.83,\n",
       " 98.04,\n",
       " 98.04,\n",
       " 15.03,\n",
       " 20.45,\n",
       " 20.45,\n",
       " 44.62,\n",
       " 71.81,\n",
       " 41.74,\n",
       " 18.43,\n",
       " 92.28,\n",
       " 32.99,\n",
       " 32.99,\n",
       " 38.77,\n",
       " 38.77,\n",
       " 63.81,\n",
       " 74.4,\n",
       " 74.4,\n",
       " 85.97,\n",
       " 88.63,\n",
       " 42.07,\n",
       " 72.37,\n",
       " 72.37,\n",
       " 75.99,\n",
       " 75.99,\n",
       " 75.99,\n",
       " 81.48,\n",
       " 91.84,\n",
       " 34.69,\n",
       " 98.09,\n",
       " 70.92,\n",
       " 91.43,\n",
       " 36.72,\n",
       " 36.72,\n",
       " 28.67,\n",
       " 30.35,\n",
       " 47.95]"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "aggressive_encounters_timing[condition]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZwAAAEXCAYAAACZNvIiAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nO3de1yO9/8H8NfdUSVyiGodnFaiElLURjS+mMMc55smhyylhzFiB9tuZszZrDCHMdM0MzHn6FdstkmROTQ5Jio5dxDV3ef3Rw/3V4t2qftQd6/n49Hj4bru+7o+7z7V/fK5Dp9LJoQQICIiUjM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x3Cx4AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Set bin edges based on desired bin size.\n",
    "percentage = 5\n",
    "nbins = int(100 / percentage) + 1\n",
    "bins = np.linspace(0, 100, num=nbins)\n",
    "\n",
    "# Plot histogram for each condition.\n",
    "for condition in condition_order:\n",
    "\n",
    "    # Initialize figure.\n",
    "    figure, axis = plt.subplots()\n",
    "    \n",
    "    # Change the bin weights, so that the sum of all bars is equal to 1 (otherwise the area under the kde curve is equal to 1, which is less interpretable).\n",
    "    bin_weights = np.ones_like(aggressive_encounters_timing[condition]) / len(aggressive_encounters_timing[condition])\n",
    "    sns.distplot(aggressive_encounters_timing[condition],\n",
    "                 bins=bins,\n",
    "                 kde=False,\n",
    "                 color='steelblue',\n",
    "                 hist_kws={'alpha': 1, 'edgecolor': INK, 'weights': bin_weights}\n",
    "                )\n",
    "    \n",
    "    # Figure and axes formatting.\n",
    "    axis.set_xlabel('Copulation Time (%)', labelpad=-15)\n",
    "    axis.set_xlim(0, 101)\n",
    "    xticklabels = [int(label) for label in axis.get_xticks()]\n",
    "    xticklabels[0] = '0\\nCopulation\\nStart'\n",
    "    xticklabels[5] = '100\\nCopulation\\nEnd'\n",
    "    axis.set_xticklabels(xticklabels)\n",
    "    axis.tick_params(axis='x', length=5)\n",
    "    axis.set_ylabel('Aggressive Encounters (%)')\n",
    "    axis.set_ylim(0, 0.16)\n",
    "    axis.set_yticklabels([int(label*100) for label in axis.get_yticks()])\n",
    "    \n",
    "    # Saving paraemetrs.\n",
    "    filename = 'aggressive_encounters_timing_distribution_during_copulation_histogram_' + condition\n",
    "    plt.savefig(os.path.join(savepath, filename))\n",
    "    \n",
    "    plt.show()\n",
    "    plt.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
